import os

model_path = os.environ.get("MODEL_PATH", "workspace")
user_path = os.environ.get("USER_PATH", "workspace")
asr_base_path = os.environ.get("ASR_PATH", "workspace")

hubert_path = os.path.join(model_path, "chinese-hubert-base")
bert_path = os.path.join(model_path, "chinese-roberta-wwm-ext-large")

gpt_weight_path = os.path.join(user_path, "general/gpt.ckpt")
sovits_weight_path = os.path.join(user_path, "general/sovits.pth")

asr_model_path = os.path.join(asr_base_path, "SenseVoiceSmall")
asr_punc_path = os.path.join(asr_base_path, "punc_ct-transformer_zh-cn-common-vocab272727-pytorch")
asr_vad_path = os.path.join(asr_base_path, "speech_fsmn_vad_zh-cn-16k-common-pytorch")

s1_pretrained = os.path.join(model_path, "gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt")
s2_pretrained_G = os.path.join(model_path, "gsv-v2final-pretrained/s2G2333k.pth")
s2_pretrained_D = os.path.join(model_path, "gsv-v2final-pretrained/s2D2333k.pth")


# check if exist
if not os.path.exists(gpt_weight_path):
  # raise ValueError(f"gpt_weight_path not exist: {gpt_weight_path}")
  print(f"gpt_weight_path not exist: {gpt_weight_path}, set to None")
  gpt_weight_path = None
if not os.path.exists(sovits_weight_path):
  # raise ValueError(f"sovits_weight_path not exist: {sovits_weight_path}")
  print(f"sovits_weight_path not exist: {sovits_weight_path}, set to None")
  sovits_weight_path = None

if not os.path.exists(hubert_path):
  raise ValueError(f"hubert_path not exist: {hubert_path}")
if not os.path.exists(bert_path):
  raise ValueError(f"bert_path not exist: {bert_path}")

if not os.path.exists(asr_model_path):
  raise ValueError(f"asr_model_path not exist: {asr_model_path}")
if not os.path.exists(asr_vad_path):
  raise ValueError(f"asr_vad_path not exist: {asr_vad_path}")
if not os.path.exists(asr_punc_path):
  raise ValueError(f"asr_punc_path not exist: {asr_punc_path}")

if not os.path.exists(s1_pretrained):
  raise ValueError(f"s1_pretrained not exist: {s1_pretrained}")
if not os.path.exists(s2_pretrained_G):
  raise ValueError(f"s2_pretrained_G not exist: {s2_pretrained_G}")
if not os.path.exists(s2_pretrained_D):
  raise ValueError(f"s2_pretrained_D not exist: {s2_pretrained_D}")